/*
 * @(#)MaintUserRoleForm.java
 *
 * Copyright (c) 2003 DCIVision Ltd
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of DCIVision
 * Ltd ("Confidential Information").  You shall not disclose such Confidential
 * Information and shall use it only in accordance with the terms of the license
 * agreement you entered into with DCIVision Ltd.
 */
package com.dcivision.user.web;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;

import com.dcivision.framework.ApplicationException;
import com.dcivision.framework.TextUtility;
import com.dcivision.framework.bean.AbstractBaseObject;
import com.dcivision.user.bean.UserRole;

/**
  MaintUserRoleForm.java

  This class is the for web form purpose.

   @author           Rollo Chan
   @company          DCIVision Limited
   @creation date    17/07/2003
   @version          $Revision: 1.5 $
*/

public class MaintUserRoleForm extends AbstractFunctionAccessForm {

  public static final String REVISION = "$Revision: 1.5 $";

  private String roleName = null;
  private String roleDesc = null;
  private String roleType = null;

  public MaintUserRoleForm() {
    super();
  }

  public String getRoleName() {
    return(this.roleName);
  }

  public void setRoleName(String roleName) {
    this.roleName = roleName;
  }

  public String getRoleDesc() {
    return(this.roleDesc);
  }

  public void setRoleDesc(String roleDesc) {
    this.roleDesc = roleDesc;
  }

  public String getRoleType() {
    return(this.roleType);
  }

  public void setRoleType(String roleType) {
    this.roleType = roleType;
  }

  public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
    return super.validate(mapping, request);
  }

  public void reset(ActionMapping mapping, HttpServletRequest request) {
    super.reset(mapping, request);
    this.setID(null);
    this.setRoleName(null);
    this.setRoleDesc(null);
    this.setRoleType(null);
    this.setRecordStatus(null);
    this.setUpdateCount(null);
    this.setCreatorID(null);
    this.setCreateDate(null);
    this.setUpdaterID(null);
    this.setUpdateDate(null);
  }

  public AbstractBaseObject getFormData() throws ApplicationException {
    UserRole tmpUserRole = new UserRole();
    tmpUserRole.setID(TextUtility.parseIntegerObj(this.getID()));
    tmpUserRole.setRoleName(this.getRoleName());
    tmpUserRole.setRoleDesc(this.getRoleDesc());
    tmpUserRole.setRoleType(this.getRoleType());
    tmpUserRole.setRecordStatus(this.getRecordStatus());
    tmpUserRole.setUpdateCount(TextUtility.parseIntegerObj(this.getUpdateCount()));
    tmpUserRole.setCreatorID(TextUtility.parseIntegerObj(this.getCreatorID()));
    tmpUserRole.setCreateDate(parseTimestamp(this.getCreateDate()));
    tmpUserRole.setUpdaterID(TextUtility.parseIntegerObj(this.getUpdaterID()));
    tmpUserRole.setUpdateDate(parseTimestamp(this.getUpdateDate()));
    return tmpUserRole;
  }

  public void setFormData(AbstractBaseObject baseObj) throws ApplicationException {
    UserRole tmpUserRole = (UserRole)baseObj;
    this.setID(TextUtility.formatIntegerObj(tmpUserRole.getID()));
    this.setRoleName(tmpUserRole.getRoleName());
    this.setRoleDesc(tmpUserRole.getRoleDesc());
    this.setRoleType(tmpUserRole.getRoleType());
    this.setRecordStatus(tmpUserRole.getRecordStatus());
    this.setUpdateCount(TextUtility.formatIntegerObj(tmpUserRole.getUpdateCount()));
    this.setCreatorID(TextUtility.formatIntegerObj(tmpUserRole.getCreatorID()));
    this.setCreateDate(formatTimestamp(tmpUserRole.getCreateDate()));
    this.setUpdaterID(TextUtility.formatIntegerObj(tmpUserRole.getUpdaterID()));
    this.setUpdateDate(formatTimestamp(tmpUserRole.getUpdateDate()));
  }
}
